<?php

require_once(WSB_MODULES_PATH .'sherpa/models/BaseGateway.php');
require_once(WSB_MODULES_PATH .'sherpa/models/Sizes.php');
require_once(WSB_MODULES_PATH .'sherpa/models/Size.php');

class Sherpa_Model_SizeGateway extends Sherpa_Model_BaseGateway
{

	/**
	 * @param integer $parentProductId
	 * @return array|Sherpa_Model_Sizes
	 */
	public function fetchParentProductSizes($parentProductId)
	{
		$select = $this->getDbSelect();
		$select->from(array('i' => 'sherpa_sizes'));
		$select->join(array('pts' => 'sherpa_productToSize'), 'i.id = pts.sizeId', array());
		$select->where('pts.parentProductId = ?', $parentProductId);
		$select->order('i.sort ASC');
		$stmt = $select->query();
		if($this->useModels()) {
			return new Sherpa_Model_Sizes($stmt->fetchAll());
		} else {
			return $stmt->fetchAll();
		}
	}

}
